from django.db import models


# Create your models here.
class Teacher(models.Model):
    tname = models.CharField('姓名', max_length=24)
    active = models.BooleanField('是否上岗', default=True)

    class Meta:
        db_table = 'tb_teacher'

    def __str__(self):
        return self.tname

    def student_count(self):
        return self.student.count()


class Student(models.Model):
    sname = models.CharField('姓名', max_length=24)
    teacher = models.ManyToManyField(Teacher, related_name='student')

    class Meta:
        db_table = 'tb_student'

    def __str__(self):
        return self.sname
